import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.*;
import java.io.File;
import java.io.IOException;
import java.awt.event.ActionEvent;

import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.UnsupportedAudioFileException;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

public class SliderGUI extends JFrame 
{
  JPanel pane=new JPanel(new GridBagLayout());
  GridBagConstraints c = new GridBagConstraints();
  JSlider slider = new JSlider();
  JSlider slider1 = new JSlider();
  JSlider slider2 = new JSlider();
  JSlider slider3 = new JSlider();
  JSlider slider4 = new JSlider();
  JSlider slider5 = new JSlider();
  JSlider slider6 = new JSlider();
  JLabel label1 = new JLabel();

  
  SliderGUI() 
  {
    super("Slider GUI"); 
    setBounds(0,300,1200,300);
    super.setResizable(false);
    setDefaultCloseOperation(HIDE_ON_CLOSE);
    Container con=this.getContentPane(); // inherit main frame
    con.add(pane); // add the panel to frame
    
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0.5;
    c.gridx = 0;
    c.gridy = 0;
    c.insets = new Insets(10,30,0,0) ;
    slider.setBorder(BorderFactory.createTitledBorder("copy"));
    slider.setOrientation(JSlider.VERTICAL);
    slider.setValue(100);
    pane.add(slider,c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0.5;
    c.gridx = 1;
    c.gridy = 0;
    c.insets = new Insets(10,10,0,30) ;
    slider1.setBorder(BorderFactory.createTitledBorder("canon"));
    slider1.setOrientation(JSlider.VERTICAL);
    slider1.setValue(0);
    pane.add(slider1,c);
    
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0.5;
    c.gridx = 2;
    c.gridy = 0;
    c.insets = new Insets(10,10,0,30) ;
    slider2.setBorder(BorderFactory.createTitledBorder("wait"));
    slider2.setOrientation(JSlider.VERTICAL);
    slider2.setValue(0);
    pane.add(slider2,c);
    
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0.5;
    c.gridx = 3;
    c.gridy = 0;
    c.insets = new Insets(10,10,0,30) ;
    slider3.setBorder(BorderFactory.createTitledBorder("section"));
    slider3.setOrientation(JSlider.VERTICAL);
    slider3.setValue(0);
    pane.add(slider3,c);
    
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0.5;
    c.gridx = 4;
    c.gridy = 0;
    c.insets = new Insets(10,10,0,30) ;
    slider4.setBorder(BorderFactory.createTitledBorder("stop cycle"));
    slider4.setOrientation(JSlider.VERTICAL);
    slider4.setValue(0);
    pane.add(slider4,c);
    
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0.5;
    c.gridx = 5;
    c.gridy = 0;
    c.insets = new Insets(10,10,0,30) ;
    slider5.setBorder(BorderFactory.createTitledBorder("stop"));
    slider5.setOrientation(JSlider.VERTICAL);
    slider5.setValue(0);
    pane.add(slider5,c);
    
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0.5;
    c.gridx = 6;
    c.gridy = 0;
    c.insets = new Insets(10,10,0,30) ;
    slider6.setBorder(BorderFactory.createTitledBorder("velocity"));
    slider6.setOrientation(JSlider.VERTICAL);
    slider6.setValue(0);
    pane.add(slider6,c);

    slider.addChangeListener(new LSlider());
    slider1.addChangeListener(new LSlider1());
    slider2.addChangeListener(new LSlider2());
    slider3.addChangeListener(new LSlider3());
    slider4.addChangeListener(new LSlider4());
    slider5.addChangeListener(new LSlider5());
    slider6.addChangeListener(new LSlider6());
    this.setVisible(true);
  }
//  public class lSlider implements ChangeListener{
//
//	@Override
//	public void stateChanged(ChangeEvent e) {
//		// TODO Auto-generated method stub
//		
//	}
//	  
//  }


  public class LSlider implements ChangeListener{
	    public void stateChanged(ChangeEvent ce){
	      int value = slider.getValue();
	      System.out.println(value);
	      Main.play.copy= value;
	    }
  }
  public class LSlider1 implements ChangeListener{
	    public void stateChanged(ChangeEvent ce){
	      int value = slider1.getValue();
	      System.out.println(value);
	      Main.play.canon=value;
	    }
  }
  public class LSlider2 implements ChangeListener{
	    public void stateChanged(ChangeEvent ce){
	      int value = slider2.getValue();
	      System.out.println("wait value  = "+value);
	      Main.play.wait=value;
	    }
}
public class LSlider3 implements ChangeListener{
	    public void stateChanged(ChangeEvent ce)
	    {
	      int value = slider3.getValue();
	      value = value/14;

	      if (value!=Main.section)
	      {
	    	  Main.play.gotoSection(value);
	      }
	      
	    }
}
public class LSlider4 implements ChangeListener{
    public void stateChanged(ChangeEvent ce)
    {
      int value = slider4.getValue();
      System.out.println("stopcycle = "+value);
//      slider2.setValue(value);
      Main.stopcycle=value;
    }
}public class LSlider5 implements ChangeListener{
    public void stateChanged(ChangeEvent ce)
    {
      int value = slider5.getValue();
      System.out.println("stop = "+value);
      Main.stop=value;
    }
}
public class LSlider6 implements ChangeListener{
    public void stateChanged(ChangeEvent ce)
    {
      int value = slider6.getValue();
      System.out.println("velocity = "+value);
      Main.velocity=value;
    }
}

}